﻿using System.Windows.Forms;
using Wise.TimeWarrior.DTO;
using Wise.TimeWarrior.Interfaces;

namespace Wise.TimeWarrior.Business.Impl
{
    /// <summary>
    /// <see cref="IWorkingDayBusinessLogic"/>
    /// </summary>
    public class WorkingDayBusinessLogic : IWorkingDayBusinessLogic
    {
        /// <summary>
        /// <see cref="IWorkingDayBusinessLogic.DataStoreService"/>
        /// </summary>
        public IDataStore DataStoreService { set; private get; }

        /// <summary>
        /// <see cref="IWorkingDayBusinessLogic.WorkingDayKeeper"/>
        /// </summary>
        public IWorkingDayKeeper WorkingDayKeeper
        {
            set;
            private get;
        }

        /// <summary>
        /// <see cref="IWorkingDayBusinessLogic.Configuration"/>
        /// </summary>
        public IConfiguration Configuration
        {
            set;
            private get;
        }

        /// <summary>
        /// <see cref="IWorkingDayBusinessLogic.GetCurrentDay"/>
        /// </summary>
        public BusinessItemDto GetCurrentDay()
        {
            BusinessItemDto miDto = new BusinessItemDto();
            miDto.ActionOption = BusinessItemOption.Visible;

            miDto.Action = () =>
            {
                WorkingDayDto wdd = WorkingDayKeeper.GetWorkingDay();
                MessageBox.Show(wdd.ToString());
            };

            return miDto;
        }

        /// <summary>
        /// <see cref="IBLSetup.SetupLogic"/>
        /// </summary>
        public void SetupLogic()
        {
            ConfigurationDto configuration = Configuration.ReadConfiguration();
            DataStoreService.DataStorePath = configuration.PathToDataStore;
        }
    }
}
